---
id: "type-parameter"
keywords: ["type", "parameter", "generics", "placeholder"]
name: "'a"
summary: "This is a `type parameter`."
category: "languageconstructs"
---

Types may be declared with [type parameters](../docs/manual/type.mdx#type-parameter-aka-generic) (also known as _generics_ in other languages) to create generalized versions of those types.

### Example with one type parameter

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type point2D<'a> = ('a, 'a)

let intPoint: point2D<int> = (1, 2)
let floatPoint: point2D<float> = (1.0, 2.0)
```

```js
var intPoint = [1, 2];
var floatPoint = [1.0, 2.0];
```

</CodeTab>

### Example with multiple type parameters

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type either<'a, 'b> = This('a) | That('b)

let value1: either<int, string> = This(123)
let value2: either<int, string> = That("Hello")
```

```js
var value1 = {
  TAG: /* This */ 0,
  _0: 123,
};

var value2 = {
  TAG: /* That */ 1,
  _0: "Hello",
};
```

</CodeTab>

### References

- [Type parameters](../docs/manual/type.mdx#type-parameter-aka-generic)
